$(document).ready(
  function()
  {  
	var list = $(".edit_block.sortableList");
	var tdDimensions = [];

	list.children('tbody').find('tr:first').children().each(function(){
		tdDimensions.push($(this).width());
	});

	list.sortable({
		axis: "y",
		items: "> tbody > tr",
		handle: '.icon-sortable',
		forcePlaceholderSize: true,
		containment: list.children('tbody'),
		tolerance: 'pointer',
		cursor: 'pointer',
		start: function(event, ui){
			ui.item.children().each(function(index){
				$(this).width(tdDimensions[index]);	
			});
		},
		update: function () { 
			var tr = list.children().children();
			tr.removeClass('first-child last-child');
			tr.first().addClass('first-child');
			tr.last().addClass('last-child');
			var sortedItems = $(this).sortable('toArray', {'attribute': 'data-sortable'});
			$(this).trigger('sorted', [sortedItems]);
		}
	}).disableSelection();
  }
);